import React from 'react';
import ReactDOM from 'react-dom';

import { BrowserRouter as Router, Route} from 'react-router-dom';
import {getQueryString} from './utils/util';

import Index from './pages/Index';
import Taoke from './pages/Taoke';
import Shuoming from './pages/Shuoming';
import GoodsInfo from './pages/GoodsInfo';
import User from './pages/User';
import Order from './pages/Order';
import Payment from './pages/Payment';
import Friends from './pages/Friends';
import Profit from './pages/Profit';
import Login from './pages/Login';
import Examine from './pages/Examine';


class BaseRouter extends React.Component{
    componentDidMount(){
        let token = getQueryString('token');
        if(token !== null){
            localStorage.setItem('token', token);
        }
    }
    render () {
        return (
            <Router>
                <div style={{height:'100%'}}>
                    <Route path="/index" component={Index} />
                    <Route path="/taoke" component={Taoke} />
                    <Route path="/shuoming" component={Shuoming} />
                    <Route path="/goods/info/:tbid/:from?" exact={true} component={GoodsInfo} />
                    <Route path="/User" component={User}/>
                    <Route path="/Order" component={Order}/>
                    <Route path="/Payment" component={Payment}/>
                    <Route path="/Friends" component={Friends}/>
                    <Route path="/Profit" component={Profit}/>
                    <Route path="/Login" component={Login}/>
                    <Route path="/Examine" component={Examine}/>
                </div>
            </Router>
        );
    }
}

ReactDOM.render(<BaseRouter />, document.getElementById('root'));
